import { readdir } from 'fs/promises'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const rootDir = join(__dirname, '../../..')

async function listDirectory(dir, indent = '') {
  try {
    const files = await readdir(dir, { withFileTypes: true })
    for (const file of files) {
      if (file.name === 'node_modules' || file.name === '.git') continue
      console.log(`${indent}${file.name}${file.isDirectory() ? '/' : ''}`)
      if (file.isDirectory()) {
        await listDirectory(join(dir, file.name), indent + '  ')
      }
    }
  } catch (err) {
    console.error(`Error reading directory ${dir}:`, err)
  }
}

console.log('Project directory structure:')
listDirectory(rootDir)
